package com.wangrui.service.impl;


import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
import com.wangrui.pojo.Semester;
import com.wangrui.mapper.SemesterMapper;
import com.wangrui.service.SemesterService;
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import java.util.HashMap;
import java.util.Map;

/**
 * <p>
 *  服务实现类
 * </p>
 *
 * @author 王锐
 * @since 2020-07-05
 */
@Service
public class SemesterServiceImpl extends ServiceImpl<SemesterMapper, Semester> implements SemesterService {
    @Autowired
    SemesterMapper semesterMapper;

    @Override
    public int getTotal() {
        return semesterMapper.selectCount(null);
    }

    @Override
    public Map<String, Object> AllSemesters(int start,int end) {
       Page<Semester> page = new Page<>(start,end);
       semesterMapper.selectPage(page,null);

        Map<String, Object> map = new HashMap<>();
        map.put("rows", page.getRecords());
        return map;
    }

    @Override
    public int semesterSave(Semester semester) {
        return semesterMapper.insert(semester);
    }

    @Override
    public int semesterUpdate(Semester semester) {
        return semesterMapper.updateById(semester);
    }

    @Override
    public int semesterDelete(int ids) {
        return semesterMapper.deleteById(ids);
    }
}
